package com.longcai.piaojia.adapter;

import android.content.Context;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.longcai.piaojia.R;
import com.zcx.helper.bound.BoundView;
import com.zcx.helper.bound.BoundViewHelper;
import com.zcx.helper.scale.ScaleScreenHelperFactory;

import java.util.List;

/**
 * Created by Administrator on 2017/1/5.
 */
public class NewsAdapter extends ArrayAdapter<String> {

    private LayoutInflater layoutInflater;
    private Context context;

    public NewsAdapter(Context context, List<String> lists) {
        super(context, 0, lists);

        this.context = context;

        layoutInflater = LayoutInflater.from(context);

    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder;

        if (convertView == null) {

            convertView = BoundViewHelper.boundView(viewHolder = new ViewHolder(), ScaleScreenHelperFactory.getInstance().loadView((ViewGroup) layoutInflater.inflate(R.layout.item_news_list, null)));

            convertView.setTag(viewHolder);

        } else {

            viewHolder = (ViewHolder) convertView.getTag();

        }

        if (position == 0) {

            viewHolder.news_list_top_tv.setVisibility(View.VISIBLE);

        } else {

            viewHolder.news_list_top_tv.setVisibility(View.GONE);

        }



        return convertView;

    }

    class ViewHolder {


        @BoundView(R.id.news_list_top_tv) private TextView news_list_top_tv;
        @BoundView(R.id.news_list_iv) private ImageView news_list_iv;
        @BoundView(R.id.news_list_title_tv) private TextView news_list_title_tv;
        @BoundView(R.id.news_list_content_tv) private TextView news_list_content_tv;
        @BoundView(R.id.news_list_time_tv) private TextView news_list_time_tv;
        @BoundView(R.id.news_list_address_tv) private TextView news_list_address_tv;

    }
}
